public class StringExercise {
    /**
     * @author Boyu Zhang
     * @date 2024/02/22
     * This class contains a set of exercises to test your understanding of the
     * methods provided by the String class. These methods can be called
     * through stringObject.method()
     * They include length(),indexOf(),substring(),equals(),compareTo().
     * In order to complete the tasks you will need to utilize above methods
     * to implement your own methods. Have a close look at the comments if you
     * have no clue where to start or not sure what exactly the scenario is like.
     */

    /**
     * @param inputString
     * @param headLength  the length of string to be trimmed from head of the given string
     * @param tailLength  the length of string to be trimmed from tail of the given string
     * @return the processed string that get the head and tail part trimmed
     * (length described by the two parameters)
     */
    public String trimHeadAndTail(String inputString, int headLength, int tailLength) {
        return null;//todo implement this
    }

    /**
     * @param inputString
     * @return boolean representing whether the head character and tail character of the string is the same
     */
    public boolean ifHeadEqualsTail(String inputString) {
        String head = null; //todo implement this
        String tail = null;//todo implement this
        if(true)//todo implement this
            return true;
        else
            return false;
    }

    /**
     * @param seg     the string segment to be matched in the target string
     * @param string1
     * @param string2
     * @return return boolean representing whether the two strings have the same string segment at the same index
     */
    public boolean ifContainsSameStringSegAtSamePlace(String seg, String string1, String string2) {
        boolean ifSame = true;
        if (true)//todo implement this
            ifSame = false;
        return ifSame;
    }

    /**
     *
     * @param string1
     * @param string2
     * @return return the string that is longer among the two given strings
     */
    public String getTheLongerString(String string1, String string2) {
        return null;//todo implement this
    }

    /**
     *
     * @param string1
     * @param string2
     * @return return the string that  is bigger if measure in alphabetic way among the two given strings
     */
    public String getTheStringWithHigherAlphabeticOrder(String string1, String string2) {
        String result = null;
        if (true)//todo implement this
            result = string2;
        else if (true)//todo implement this
            result = string1;
        else
            result = string2;

        return result;
    }

    public static void main(String[] args) {
        StringExercise se = new StringExercise();
        System.out.println("Testing Method " +
                "trimHeadAndTail(String inputString, int headLength, int tailLength)");
        System.out.println("Expected Result: CD");
        System.out.println("Actual Result: " + se.trimHeadAndTail("ABCDE", 2, 1));

        System.out.println("-------------");
        System.out.println("Testing Method ifHeadEqualsTail(String inputString)");
        System.out.println("Expected Result: true");
        System.out.println("Actual Result: " + se.ifHeadEqualsTail("SadsfsdS"));
        System.out.println("Expected Result: false");
        System.out.println("Actual Result: " + se.ifHeadEqualsTail("SadH"));

        System.out.println("-------------");
        System.out.println("Testing Method " +
                "ifContainsSameStringSegAtSamePlace(String seg, String string1, String string2)");
        System.out.println("Expected Result: true");
        System.out.println("Actual Result: " + se.ifContainsSameStringSegAtSamePlace("ello", "Jello Rio", "Hello"));
        System.out.println("Expected Result: false");
        System.out.println("Actual Result: " + se.ifContainsSameStringSegAtSamePlace("ello", "Jelo Rio", "Hello"));

        System.out.println("-------------");
        System.out.println("Testing Method getTheLongerString(String string1, String string2)");
        System.out.println("Expected Result: apple");
        System.out.println("Actual Result: " + se.getTheLongerString("123", "apple"));

        System.out.println("-------------");
        System.out.println("Testing Method " +
                "getTheStringWithHigherAlphabeticOrder(String string1, String string2)");
        System.out.println("Expected Result: d");
        System.out.println("Actual Result: " + se.getTheStringWithHigherAlphabeticOrder("d", "c"));
    }
}

